import java.util.Scanner;

public class Solution {
    public int maxArea(int[] height){
        int len = height.length;
        int left = 0,right = len-1,ret = 0;
        while(left < right){
            int v = Math.min(height[left], height[right]) * (right-left);
            ret = Math.max(ret,v);
            if(height[left] < height[right]){
                left++;
            }else{
                right--;
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int size = in.nextInt();
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = in.nextInt();
            }
            Solution solution = new Solution();
            int volume = solution.maxArea(arr);
            System.out.println(volume);
        }
    }
}
